from sys import exit
from random import choice
from termcolor import cprint
import time

red = 'red'
green = 'green'
yellow = 'yellow'
blue = 'blue'
magenta = 'magenta'
white = 'white'
cyan = 'cyan'

my_colors = [red, green, yellow, blue, magenta, white, cyan]
my_words = ["red", "green", "yellow", "blue", "magenta", "white", "cyan"]

def start():
    print "\nColor guessing game! The game is very simple. A word will appear on the screen."
    print "Your job is to guess the COLOR of the word printed to the screen. These are your choices: "
    cprint("red", 'red')
    cprint("green", 'green')
    cprint("yellow", 'yellow')
    cprint("blue", 'blue')
    cprint("magenta", 'magenta')
    cprint("white", 'white')
    cprint("cyan", 'cyan')
    print "\nYou will have 10 tries. Ready? Type y to proceed, and any other letter to exit."
    proceed = raw_input("> ")
    if proceed.lower() == 'y':
        guess_color()
    else:
        print "Goodbye!"
        exit(0)

def guess_color():
    attempt = 0
    score = 0
    start_time = time.time()
    while attempt < 10:
        attempt += 1
        guess_word = choice(my_words)
        guess_color = choice(my_colors)
        print "Try: %d" % attempt
        cprint(guess_word, guess_color)
        guess = raw_input("> ")
        if guess == guess_color:
            score += 1
        else:
            score = score
    elapsed_time = time.time() - start_time
    print "Your score is: %d" % score
    print "It took you this many seconds: %d" % int(elapsed_time)

start()
